//
//  RecommendedCollectionViewCell.m
//  Food
//
//  Created by 15 on 15/7/14.
//  Copyright (c) 2015年 李志远. All rights reserved.
//

#import "RecommendedCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation RecommendedCollectionViewCell

- (void)dealloc
{
    [_lblName release];
    [_viewRecommend release];
    [_imgRecommend release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.viewRecommend = [[[UIView alloc] init] autorelease];
        [self.contentView addSubview:self.viewRecommend];
        self.imgRecommend = [[[UIImageView alloc] init] autorelease];
        [self.viewRecommend addSubview:self.imgRecommend];
        self.lblName = [[[UILabel alloc] init] autorelease];
        [self.imgRecommend addSubview:self.lblName];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.viewRecommend.frame = CGRectMake(0, 0, 320, 200);
    self.viewRecommend.backgroundColor = [UIColor whiteColor];
    self.imgRecommend.frame = CGRectMake(10, 10, 300, 180);
    self.imgRecommend.backgroundColor = [UIColor blackColor];
    self.lblName.frame = CGRectMake(10, 150, 150, 20);
    self.lblName.shadowColor = [UIColor blackColor];
    self.lblName.shadowOffset = CGSizeMake(1, 1);
    self.lblName.textColor = [UIColor whiteColor];
}

- (void)setModel:(RecommendModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.lblName.text = self.model.name;
    [self.imgRecommend setImageWithURL:[NSURL URLWithString:self.model.img] placeholderImage:[UIImage imageNamed:@"placeholder"]];
}

@end
